<?php ini_set("precision","3"); ?>
<?php
         $a = Doctrine::getTable('BbPlayerStat')->getAvgStatsBySeason($seasonId, $orderByColumn, $order)
?>
<?php $season = Doctrine::getTable('BbSeason')->findOneBySId($seasonId)?>
<?php $league = Doctrine::getTable('BbLeague')->findOneById($season->getLId())?>
<?php $even=1;?>
<div class="column-left" >
<div class="gn_box" width="100%">	
    <div class="news-title"><?php echo $league." :: ".$season ?></div>	
<div class="tableStat" width="90%">
<table class="statTable" >  
  <tr>
    <td nowrap valign="top" style="padding:0;border:0;">
        <table style="width:40%;float:left;">
          <thead>
            <tr class="trhead"">
              <th>Тоглогч</th>
              <th>Байр</th>
              <th>Баг</th>
              <th>Т</th>
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('Fgm', '@stat_index?seasonId='.$seasonId.'&orderByColumn=fgm&order=asc');
	              else 
	                echo '&darr;'.link_to('Fgm', '@stat_index?seasonId='.$seasonId.'&orderByColumn=fgm&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('FGA', '@stat_index?seasonId='.$seasonId.'&orderByColumn=fga&order=asc');
	              else 
	                echo '&darr;'.link_to('FGA', '@stat_index?seasonId='.$seasonId.'&orderByColumn=fga&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('3PtsM', '@stat_index?seasonId='.$seasonId.'&orderByColumn=pt3m&order=asc');
	              else 
	                echo '&darr;'.link_to('3PtsM', '@stat_index?seasonId='.$seasonId.'&orderByColumn=pt3m&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('3PtsA', '@stat_index?seasonId='.$seasonId.'&orderByColumn=pt3a&order=asc');
	              else 
	                echo '&darr;'.link_to('3PtsA', '@stat_index?seasonId='.$seasonId.'&orderByColumn=pt3a&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('Ftm', '@stat_index?seasonId='.$seasonId.'&orderByColumn=ftm&order=asc');
	              else 
	                echo '&darr;'.link_to('Ftm', '@stat_index?seasonId='.$seasonId.'&orderByColumn=ftm&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('Fta', '@stat_index?seasonId='.$seasonId.'&orderByColumn=fta&order=asc');
	              else 
	                echo '&darr;'.link_to('Fta', '@stat_index?seasonId='.$seasonId.'&orderByColumn=fta&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('Off', '@stat_index?seasonId='.$seasonId.'&orderByColumn=off&order=asc');
	              else 
	                echo '&darr;'.link_to('Off', '@stat_index?seasonId='.$seasonId.'&orderByColumn=off&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('Reb', '@stat_index?seasonId='.$seasonId.'&orderByColumn=reb&order=asc');
	              else 
	                echo '&darr;'.link_to('Reb', '@stat_index?seasonId='.$seasonId.'&orderByColumn=reb&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('Ast', '@stat_index?seasonId='.$seasonId.'&orderByColumn=ast&order=asc');
	              else 
	                echo '&darr;'.link_to('Ast', '@stat_index?seasonId='.$seasonId.'&orderByColumn=ast&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('Stl', '@stat_index?seasonId='.$seasonId.'&orderByColumn=stl&order=asc');
	              else 
	                echo '&darr;'.link_to('Stl', '@stat_index?seasonId='.$seasonId.'&orderByColumn=stl&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('Blk', '@stat_index?seasonId='.$seasonId.'&orderByColumn=blk&order=asc');
	              else 
	                echo '&darr;'.link_to('Blk', '@stat_index?seasonId='.$seasonId.'&orderByColumn=blk&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('TO', '@stat_index?seasonId='.$seasonId.'&orderByColumn=tov&order=asc');
	              else 
	                echo '&darr;'.link_to('TO', '@stat_index?seasonId='.$seasonId.'&orderByColumn=tov&order=desc');
	              ?>
              </th> 
               <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('Pf', '@stat_index?seasonId='.$seasonId.'&orderByColumn=pf&order=asc');
	              else 
	                echo '&darr;'.link_to('Pf', '@stat_index?seasonId='.$seasonId.'&orderByColumn=pf&order=desc');
	              ?>
              </th> 
              <th>
	              <?php 
	              if($order == "desc")
	                echo '&uarr;'.link_to('Pts', '@stat_index?seasonId='.$seasonId.'&orderByColumn=pts&order=asc');
	              else 
	                echo '&darr;'.link_to('Pts', '@stat_index?seasonId='.$seasonId.'&orderByColumn=pts&order=desc');
	              ?>
              </th> 
            </tr>
          </thead>
            <tbody>
              <?php foreach ($a as $key=>$value): ?>
              	<?php $player = Doctrine::getTable('BbPlayers')->findOneById($value['playerId']); ?>
              	<?php $position = Doctrine::getTable('BbPositions')->findOneByPId($player->getPositionId()); ?>
              	<?php $team = Doctrine::getTable('BbTeams')->findOneById($player->getTeamId()); ?>
              	<tr class="<?php if ($even==1) echo 'even'; else echo 'odd'; ?>">
              		<td><a href="/players/<?php echo $player->getNick()?>"><?php echo $player->getFullname() ?></a></td>
              		<td><?php echo mb_substr($position, 0, 3, 'UTF-8') ?></td>
              		<td><a href="/teams/<?php echo $team->getTName()?>"><?php echo $team ?></a></td>
              		<td><?php echo $value['gp'] ?></td>
              		<td><?php echo $value['fgm'] ?></td>
              		<td><?php echo $value['fga'] ?></td>
              		<td><?php echo $value['pt3m'] ?></td>
              		<td><?php echo $value['pt3a'] ?></td>
              		<td><?php echo $value['ftm'] ?></td>
              		<td><?php echo $value['fta'] ?></td>
              		<td><?php echo $value['off'] ?></td>
              		<td><?php echo $value['reb'] ?></td>
              		<td><?php echo $value['ast'] ?></td>
              		<td><?php echo $value['stl'] ?></td>
              		<td><?php echo $value['blk'] ?></td>
              		<td><?php echo $value['tov'] ?></td>
              		<td><?php echo $value['pf'] ?></td>
              		<td><?php echo $value['pts'] ?></td>           		
              	</tr>
            	<?php if ($even==1) $even=1; else $even=1; endforeach;?>
          </tbody>
        </table>
    </td>
    </tr>
    </td>
  </tr>
</table>
</div>
</div>
</div>

<?php include_partial('main/right', array());?>

<br clear="all">
<script type="text/javascript">
 
</script>
